package org.xtext.example.generator

import org.eclipse.xtext.generator.IFileSystemAccess
import org.eclipse.emf.ecore.resource.Resource
import org.eclipse.xtext.generator.IFileSystemAccess

class GenUtils {
	IFileSystemAccess curFsa
	Resource resource
	
	def setFsa(IFileSystemAccess fsa) {
		curFsa = fsa
	}
	
	def IFileSystemAccess getFsa() {
		return curFsa
	}
	
	def setResource(Resource res) {
		resource = res
	}
	
	def Resource getResource() {
		return resource
	}
	
	def genFile(String name, String suffix, CharSequence contents) {
		var sysName = name.replace(".", "/")
		var fName = applicationDirName() + "/" + sysName + "." + suffix
		curFsa.generateFile(fName, contents)
	}
	
	def applicationDirName() {
		""
	}
	
	def applicationPackageName() {
		""
	}
	
	def genLogo() '''
	/*
	 * --------------------------------------
	 * Generated by AN
	 * --------------------------------------
	 */
	'''
}